home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / MFC / include / afxmt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  5.4 KB  |  256 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. #ifndef __AFXMT_H__
  12. #define __AFXMT_H__
  13.  
  14. #ifndef __AFX_H__
  15.     #include <afx.h>
  16. #endif
  17.  
  18. #ifdef _AFX_MINREBUILD
  19. #pragma component(minrebuild, off)
  20. #endif
  21. #ifndef _AFX_FULLTYPEINFO
  22. #pragma component(mintypeinfo, on)
  23. #endif
  24.  
  25. #ifdef _AFX_PACKING
  26. #pragma pack(push, _AFX_PACKING)
  27. #endif
  28.  
  29. /////////////////////////////////////////////////////////////////////////////
  30. // AFXMT - MFC Multithreaded Extensions (Syncronization Objects)
  31.  
  32. // Classes declared in this file
  33.  
  34. //CObject
  35.     class CSyncObject;
  36.         class CSemaphore;
  37.         class CMutex;
  38.         class CEvent;
  39.         class CCriticalSection;
  40.  
  41. class CSingleLock;
  42. class CMultiLock;
  43.  
  44. #undef AFX_DATA
  45. #define AFX_DATA AFX_CORE_DATA
  46.  
  47. /////////////////////////////////////////////////////////////////////////////
  48. // Basic synchronization object
  49.  
  50. class CSyncObject : public CObject
  51. {
  52.     DECLARE_DYNAMIC(CSyncObject)
  53.  
  54. // Constructor
  55. public:
  56.     CSyncObject(LPCTSTR pstrName);
  57.  
  58. // Attributes
  59. public:
  60.     operator HANDLE() const;
  61.     HANDLE  m_hObject;
  62.  
  63. // Operations
  64.     virtual BOOL Lock(DWORD dwTimeout = INFINITE);
  65.     virtual BOOL Unlock() = 0;
  66.     virtual BOOL Unlock(LONG /* lCount */, LPLONG /* lpPrevCount=NULL */)
  67.         { return TRUE; }
  68.  
  69. // Implementation
  70. public:
  71.     virtual ~CSyncObject();
  72. #ifdef _DEBUG
  73.     CString m_strName;
  74.     virtual void AssertValid() const;
  75.     virtual void Dump(CDumpContext& dc) const;
  76. #endif
  77.     friend class CSingleLock;
  78.     friend class CMultiLock;
  79. };
  80.  
  81. #if !defined(_WIN32_WCE)
  82. /////////////////////////////////////////////////////////////////////////////
  83. // CSemaphore
  84.  
  85. class CSemaphore : public CSyncObject
  86. {
  87.     DECLARE_DYNAMIC(CSemaphore)
  88.  
  89. // Constructor
  90. public:
  91.     CSemaphore(LONG lInitialCount = 1, LONG lMaxCount = 1,
  92.         LPCTSTR pstrName=NULL, LPSECURITY_ATTRIBUTES lpsaAttributes = NULL);
  93.  
  94. // Implementation
  95. public:
  96.     virtual ~CSemaphore();
  97.     virtual BOOL Unlock();
  98.     virtual BOOL Unlock(LONG lCount, LPLONG lprevCount = NULL);
  99. };
  100.  
  101. /////////////////////////////////////////////////////////////////////////////
  102. // CMutex
  103.  
  104. class CMutex : public CSyncObject
  105. {
  106.     DECLARE_DYNAMIC(CMutex)
  107.  
  108. // Constructor
  109. public:
  110.     CMutex(BOOL bInitiallyOwn = FALSE, LPCTSTR lpszName = NULL,
  111.         LPSECURITY_ATTRIBUTES lpsaAttribute = NULL);
  112.  
  113. // Implementation
  114. public:
  115.     virtual ~CMutex();
  116.     BOOL Unlock();
  117. };
  118. #endif // _WIN32_WCE
  119.  
  120. /////////////////////////////////////////////////////////////////////////////
  121. // CEvent
  122.  
  123. class CEvent : public CSyncObject
  124. {
  125.     DECLARE_DYNAMIC(CEvent)
  126.  
  127. // Constructor
  128. public:
  129.     CEvent(BOOL bInitiallyOwn = FALSE, BOOL bManualReset = FALSE,
  130.         LPCTSTR lpszNAme = NULL, LPSECURITY_ATTRIBUTES lpsaAttribute = NULL);
  131.  
  132. // Operations
  133. public:
  134.     BOOL SetEvent();
  135.     BOOL PulseEvent();
  136.     BOOL ResetEvent();
  137.     BOOL Unlock();
  138.  
  139. // Implementation
  140. public:
  141.     virtual ~CEvent();
  142. };
  143.  
  144. /////////////////////////////////////////////////////////////////////////////
  145. // CCriticalSection
  146.  
  147. class CCriticalSection : public CSyncObject
  148. {
  149.     DECLARE_DYNAMIC(CCriticalSection)
  150.  
  151. // Constructor
  152. public:
  153.     CCriticalSection();
  154.  
  155. // Attributes
  156. public:
  157.     operator CRITICAL_SECTION*();
  158.     CRITICAL_SECTION m_sect;
  159.  
  160. // Operations
  161. public:
  162.     BOOL Unlock();
  163.     BOOL Lock();
  164.     BOOL Lock(DWORD dwTimeout);
  165.  
  166. // Implementation
  167. public:
  168.     virtual ~CCriticalSection();
  169. };
  170.  
  171. /////////////////////////////////////////////////////////////////////////////
  172. // CSingleLock
  173.  
  174. class CSingleLock
  175. {
  176. // Constructors
  177. public:
  178.     CSingleLock(CSyncObject* pObject, BOOL bInitialLock = FALSE);
  179.  
  180. // Operations
  181. public:
  182.     BOOL Lock(DWORD dwTimeOut = INFINITE);
  183.     BOOL Unlock();
  184.     BOOL Unlock(LONG lCount, LPLONG lPrevCount = NULL);
  185.     BOOL IsLocked();
  186.  
  187. // Implementation
  188. public:
  189.     ~CSingleLock();
  190.  
  191. protected:
  192.     CSyncObject* m_pObject;
  193.     HANDLE  m_hObject;
  194.     BOOL    m_bAcquired;
  195. };
  196.  
  197. #if !defined(_WIN32_WCE)
  198. /////////////////////////////////////////////////////////////////////////////
  199. // CMultiLock
  200.  
  201. class CMultiLock
  202. {
  203. // Constructor
  204. public:
  205.     CMultiLock(CSyncObject* ppObjects[], DWORD dwCount, BOOL bInitialLock = FALSE);
  206.  
  207. // Operations
  208. public:
  209.     DWORD Lock(DWORD dwTimeOut = INFINITE, BOOL bWaitForAll = TRUE,
  210.         DWORD dwWakeMask = 0);
  211.     BOOL Unlock();
  212.     BOOL Unlock(LONG lCount, LPLONG lPrevCount = NULL);
  213.     BOOL IsLocked(DWORD dwItem);
  214.  
  215. // Implementation
  216. public:
  217.     ~CMultiLock();
  218.  
  219. protected:
  220.     HANDLE  m_hPreallocated[8];
  221.     BOOL    m_bPreallocated[8];
  222.  
  223.     CSyncObject* const * m_ppObjectArray;
  224.     HANDLE* m_pHandleArray;
  225.     BOOL*   m_bLockedArray;
  226.     DWORD   m_dwCount;
  227. };
  228. #endif // _WIN32_WCE
  229.  
  230. /////////////////////////////////////////////////////////////////////////////
  231. // Inline function declarations
  232.  
  233. #ifdef _AFX_PACKING
  234. #pragma pack(pop)
  235. #endif
  236.  
  237. #ifdef _AFX_ENABLE_INLINES
  238. #define _AFXMT_INLINE AFX_INLINE
  239. #include <afxmt.inl>
  240. #undef _AFXMT_INLINE
  241. #endif
  242.  
  243. #undef AFX_DATA
  244. #define AFX_DATA
  245.  
  246. #ifdef _AFX_MINREBUILD
  247. #pragma component(minrebuild, on)
  248. #endif
  249. #ifndef _AFX_FULLTYPEINFO
  250. #pragma component(mintypeinfo, off)
  251. #endif
  252.  
  253. #endif  // __AFXMT_H__
  254.  
  255. /////////////////////////////////////////////////////////////////////////////
  256.